import { Map } from 'immutable'

import * as actionTypes from './constants'

const defaultState = Map({
  topBanners: [],
  coverList: [],
  newAlbum: [],
  rank1: {},
  rank2: {},
  rank3: {},
  artists: []
})

export default function reducer(state = defaultState, action) {
  switch(action.type) {
    case actionTypes.CHANGE_TOP_BANNER:
      return state.set("topBanners", action.banners)
    case actionTypes.CHANGE_COVER_LIST:
      return state.set("coverList", action.cover)
    case actionTypes.CHANGE_NEW_ALBUM:
      return state.set("newAlbum", action.album)
    case actionTypes.CHANGE_RANK_LIST1:
      return state.set("rank1",action.rank)
    case actionTypes.CHANGE_RANK_LIST2:
      return state.set("rank2",action.rank)
    case actionTypes.CHANGE_RANK_LIST3:
      return state.set("rank3",action.rank)
    case actionTypes.CHANGE_IN_SINGER:
      return state.set("artists",action.artists)
    default:
      return state
  }
}